import React, { createContext, useReducer } from 'react';

import { initState, publicDataReducer } from './Reducer';

export const PublicDataStore = createContext(null);

export const PublicDataProvider = ({ children }) => {
  const [state, dispatch] = useReducer(publicDataReducer, initState);

  return (
    <PublicDataStore.Provider value={{ state, dispatch }}>
      {children}
    </PublicDataStore.Provider>
  )
};
